package test1225;


public class Test14 {
    public static void main(String[] args) {
        // 打印10-20之间各个数的素数因子
        m14(10, 20);
    }
    public static void m14(int a, int b) {
         for (int i = a; i <= b; i++) {
             if (findYin(i)[0] == -1) {
                 System.out.println();
                 System.out.print(i+"小于等于1，不满足条件");
             }else if (findYin(i)[0]!=i){
                 System.out.println();
                 System.out.print(i+"的素数因子为:");
                 for(int j=0;j<findYin(i).length;j++){
                     System.out.print(findYin(i)[j] + " ");
                 }
             } else{
                 System.out.println();
                 System.out.print(i+"是素数");
             }
         }
    }

    public static int[] findYin(int a) {
        int[] lin_arr = new int[100];
        int jiao = 0;
        if(a <= 1){
            lin_arr[0] = -1;
            return lin_arr;
        }
        for(int i = 2; i <= a; i++){
            while(a%i == 0){
                lin_arr[jiao] = i;
                a /= i;
                jiao++;
            }
        }

        int[] f = new int[jiao];
        for(int i = 0; i < jiao; i++){
            f[i] = lin_arr[i];
        }
        return f;

    }


}